package com.yunlankeji.stemcells.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.yunlankeji.ganxibaozhijia.R;
import com.yunlankeji.stemcells.model.request.Personal_space;

import java.util.List;

public class Fragment_personal_space_followAdapter extends RecyclerView.Adapter<Fragment_personal_space_followAdapter.MyViewHolder> {

    private List<Personal_space>personal_spaceList;

    public Fragment_personal_space_followAdapter(List<Personal_space> personal_spaceList) {
        this.personal_spaceList = personal_spaceList;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemview = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_item_personal_space_follow,parent,false);
        MyViewHolder myViewHolder=new MyViewHolder(itemview);
        return myViewHolder;

    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        Personal_space personal_space=personal_spaceList.get(position);
        holder.name.setText(personal_space.getName());
        holder.userType.setText(personal_space.getUserType());
        holder.followType.setText(personal_space.getFolloeType());
        holder.head.setImageResource(personal_space.getHeadId());
    }

    @Override
    public int getItemCount() {
        return personal_spaceList.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        TextView name;
        TextView userType;
        TextView followType;
        ImageView head;

        public MyViewHolder(View itemView) {
            super(itemView);
            this.name = itemView.findViewById(R.id.personal_space_follow_name_tx);
            this.userType = itemView.findViewById(R.id.personal_space_follow_user_Type);
            this.followType = itemView.findViewById(R.id.personal_space_follow_Type);
            this.head = itemView.findViewById(R.id.iv_mine_personal_space_follow);
        }
    }
}
